package cn.chenfeifx.core.controls;

import cn.chenfeifx.core.controls.skins.CFEmptySkin;
import cn.chenfeifx.core.common.SimpleControl;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.scene.Node;
import javafx.scene.control.Control;
import javafx.scene.control.Label;
import javafx.scene.control.Skin;

public class CFEmpty extends Control {

    private final Label textLabel = SimpleControl.getLabel("赞无数据");
    private final ObjectProperty<Node> bottomNode = new SimpleObjectProperty<>(textLabel);
    private final DoubleProperty size = new SimpleDoubleProperty(200);

    public CFEmpty() {
        initialize();
    }

    public CFEmpty(String text) {
        textLabel.setText(text);
        initialize();
    }

    public CFEmpty(double size, Node node) {
        bottomNode.set(node);
        setSize(size);
        initialize();
    }

    public double getSize() {
        return size.get();
    }

    public DoubleProperty sizeProperty() {
        return size;
    }

    public void setSize(double size) {
        this.size.set(size);
    }

    public Node getBottomNode() {
        return bottomNode.get();
    }

    public void setBottomNode(Node bottomNode) {
        this.bottomNode.set(bottomNode);
    }

    public ObjectProperty<Node> bottomNodeProperty() {
        return bottomNode;
    }

    private void initialize() {
        setMaxSize(USE_COMPUTED_SIZE, USE_COMPUTED_SIZE);
    }

    @Override
    protected Skin<?> createDefaultSkin() {
        return new CFEmptySkin(this);
    }
}
